pub fn rank(key: i32, v: &Vec<i32>) -> i32 {
    let mut lo = 0i32;
    let mut hi = v.len() as i32 - 1i32;
    while lo <= hi {
        let mid = lo + (hi - lo) / 2;
        if key < v[mid as usize] {
            hi = mid as i32 - 1;
        } else if key > v[mid as usize] {
            lo = mid as i32 + 1;
        } else {
            return mid;
        }
    }
    -1i32
}
